<template>
  <div>
      
          <p>账号：<input type="text" v-model="username"></p>
          <p>密码：<input type="text" v-model="password"></p>
          <p><button @click="sub">点咱登录</button></p>
          
  </div>
</template>

<script>
import axios from 'axios'
export default {
data() {
    return {
        username:'',
        password:'',
    }
},
methods:{
    sub(){
        let data = new FormData()
        data.append('username',this.username)
        data.append('password',this.password)
        axios.post('http://127.0.0.1:8000/my/login/',data).then(resp=>{
            console.log(resp.data)
            alert(resp.data.msg)
            sessionStorage.setItem('uid',resp.data.uid)
            sessionStorage.setItem('username',this.username)
            this.$router.push('/index')
        }).catch(err=>{
            console.log(err)
        })
    }
}
}
</script>

<style>

</style>